package com.example.project_springboot.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Slf4j
public class WebAop {
    @Around("execution(* com.example.project_springboot.service.EmpService.*(..))")
    public Object recordTime(ProceedingJoinPoint pjp) throws Throwable {
        long start = System.currentTimeMillis();
        Object o = pjp.proceed();
        long end = System.currentTimeMillis();
        log.info(pjp.getSignature() +"执行消耗时间{}",(end-start)+"ms");
        return o;
    }
}
